from os import name
from django.db import models
from django.utils import timezone

# Create your models here.

SEC_CHOICE = (("0", "男"),("1","女"))
LEARNED_CHOICE = (("0", "未开始"), ("1","已开始"), ("2", "已学完"))

class CallNotes(models.Model):
    # 姓名、  性别、  年龄 、 电话  、客户种类（未学 已学  ）、是否已联系 、客户意向、  分析备注
    phone = models.CharField(max_length=11, verbose_name='手机号')
    name = models.CharField(max_length=5, verbose_name='姓名', null=True, blank=True)
    sex = models.CharField(max_length=1, verbose_name='性别', default=0, choices=SEC_CHOICE)
    learned = models.CharField(max_length=1, verbose_name='学习状态', default=0, choices=LEARNED_CHOICE)
    age = models.IntegerField(verbose_name='年龄', default=0)
    place = models.CharField(max_length=255, verbose_name="地区", help_text="省-市-县",blank=True, null=True)
    school = models.CharField(max_length=20, verbose_name="学校名称",blank=True, null=True)
    intention = models.CharField(max_length=1, verbose_name='意向程度', default=0)

    def __str__(self):
        return str(self.phone)

    class Meta:
        ordering = ('-pk',)
        verbose_name_plural = '电话记录'


class CallDetail(models.Model):
    message = models.TextField(verbose_name="聊天内容")
    analysis = models.TextField(verbose_name="分析备注", blank=True, null=True)
    create_time = models.DateTimeField(default=timezone.now, verbose_name="记录时间")
    belong_note = models.ForeignKey(to=CallNotes, verbose_name="所属笔记", on_delete=models.CASCADE)

    def __str__(self):
        return str(self.belong_note.phone)

    class Meta:
        ordering = ('-pk',)
        verbose_name_plural = '电话详情'